import request from '../../../util/request';
import {userServer} from '../../../config/config';

/**
 * 更新用户
 */
function updateUser({userId, avatarId, username, email, mobilePhone, password, nickname, realName, idCard, sex, birthTime, status}) {
	return request(userServer('/api/user/updateUser'), {
		data: {userId, avatarId, username, email, mobilePhone, password, nickname, realName, idCard, sex, birthTime, status}
	});
}

/**
 * 同步角色
 */
function synRole({userId, roleIds}) {
	return request(userServer('/api/user/synRole'), {
		data: {userId, roleIds}
	});
}

/**
 * 添加用户角色
 */
function addRole({userId, roleIds}) {
	return request(userServer('/api/user/addRole'), {
		data: {userId, roleIds}
	});
}

/**
 * 移除用户角色
 */
function removeRole({userId, roleIds}) {
	return request(userServer('/api/user/removeRole'), {
		data: {userId, roleIds}
	});
}

/**
 * 分页获取用户
 */
function pageUser({pageNum, pageSize}) {
	return request(userServer('/api/user/pageUser'), {
		data: {pageNum, pageSize}
	});
}

export {
	updateUser,
	synRole,
	addRole,
	removeRole,
	pageUser,
}
